home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / fpc / amigaunits / asl.pas < prev    next >
Pascal/Delphi Source File  |  2000-01-01  |  20KB  |  547 lines

  1. {
  2.     This file is part of the Free Pascal run time library.
  3.  
  4.     A file in Amiga system run time library.
  5.     Copyright (c) 1998-2000 by Nils Sjoholm
  6.     member of the Amiga RTL development team.
  7.  
  8.     See the file COPYING.FPC, included in this distribution,
  9.     for details about the copyright.
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14.  
  15.  **********************************************************************}
  16.  
  17. {
  18.     History:
  19.  
  20.     Found a bug in tFileRequester, rt_ArgList had pWBArg as arg
  21.     should be pWBArgList. Fixed
  22.     27 Oct 1998.
  23.  
  24.     Added autoopening of asl.library.
  25.     28 Oct 1998.
  26.  
  27.     Added MessageBox for error report.
  28.     31 Jul 2000.
  29.  
  30.     nils.sjoholm@mailbox.swipnet.se
  31. }
  32.  
  33.  
  34. UNIT asl;
  35.  
  36. INTERFACE
  37. uses exec, utility, workbench, graphics;
  38.  
  39. {************************************************************************}
  40.  
  41. CONST
  42.   ASLNAME : PChar = 'asl.library';
  43.   ASL_TB          =     TAG_USER+$80000;
  44.  
  45. {************************************************************************}
  46.  
  47. { Types of requesters known to ASL, used as arguments to AllocAslRequest() }
  48.   ASL_FileRequest       = 0;
  49.   ASL_FontRequest       = 1;
  50.   ASL_ScreenModeRequest = 2;
  51.  
  52.  
  53. {****************************************************************************
  54.  *
  55.  * ASL File Requester data structures and constants
  56.  *
  57.  * This structure must only be allocated by asl.library amd is READ-ONLY!
  58.  * Control of the various fields is provided via tags when the requester
  59.  * is created with AllocAslRequest() and when it is displayed via
  60.  * AslRequest()
  61.  }
  62.  
  63. Type
  64.        pFileRequester = ^tFileRequester;
  65.        tFileRequester = record
  66.            rf_Reserved0   : Array[0..3] Of Byte;
  67.            rf_File        : STRPTR;        { Filename pointer             }
  68.            rf_Dir         : STRPTR;        { Directory name pointer       }
  69.            rf_Reserved1   : Array[0..9] Of Byte;
  70.            rf_LeftEdge    : Integer;
  71.            rf_TopEdge     : Integer;          { Preferred window pos }
  72.            rf_Width       : Integer;
  73.            rf_Height      : Integer;          { Preferred window size  }
  74.            rf_Reserved2   : Array[0..1] Of Byte;
  75.            rf_NumArgs     : LongInt;       { A-la WB Args, FOR multiselects }
  76.            rf_ArgList     : pWBArgList;
  77.            rf_UserData    : Pointer;       { Applihandle (you may write!!) }
  78.            rf_Reserved3   : Array[0..7] Of Byte;
  79.            rf_Pat         : STRPTR;        { Pattern match pointer }
  80.        END;                                { note - more reserved fields follow }
  81.  
  82.  
  83. { File requester tag values, used by AllocAslRequest() and AslRequest() }
  84.  
  85. const
  86. { Window control }
  87.   ASLFR_Window         = ASL_TB+2 ;  { Parent window                    }
  88.   ASLFR_Screen         = ASL_TB+40;  { Screen to open on if no window   }
  89.   ASLFR_PubScreenName  = ASL_TB+41;  { Name of public screen            }
  90.   ASLFR_PrivateIDCMP   = ASL_TB+42;  { Allocate private IDCMP?          }
  91.   ASLFR_IntuiMsgFunc   = ASL_TB+70;  { Function to handle IntuiMessages }
  92.   ASLFR_SleepWindow    = ASL_TB+43;  { Block input in ASLFR_Window?     }
  93.   ASLFR_UserData       = ASL_TB+52;  { What to put in fr_UserData       }
  94.  
  95. { Text display }
  96.   ASLFR_TextAttr       = ASL_TB+51;  { Text font to use for gadget text }
  97.   ASLFR_Locale         = ASL_TB+50;  { Locale ASL should use for text   }
  98.   ASLFR_TitleText      = ASL_TB+1 ;  { Title of requester               }
  99.   ASLFR_PositiveText   = ASL_TB+18;  { Positive gadget text             }
  100.   ASLFR_NegativeText   = ASL_TB+19;  { Negative gadget text             }
  101.  
  102. { Initial settings }
  103.   ASLFR_InitialLeftEdge= ASL_TB+3 ;  { Initial requester coordinates    }
  104.   ASLFR_InitialTopEdge = ASL_TB+4 ;
  105.   ASLFR_InitialWidth   = ASL_TB+5 ;  { Initial requester dimensions     }
  106.   ASLFR_InitialHeight  = ASL_TB+6 ;
  107.   ASLFR_InitialFile    = ASL_TB+8 ;  { Initial contents of File gadget  }
  108.   ASLFR_InitialDrawer  = ASL_TB+9 ;  { Initial contents of Drawer gadg. }
  109.   ASLFR_InitialPattern = ASL_TB+10;  { Initial contents of Pattern gadg.}
  110.  
  111. { Options }
  112.   ASLFR_Flags1         = ASL_TB+20;  { Option flags                     }
  113.   ASLFR_Flags2         = ASL_TB+22;  { Additional option flags          }
  114.   ASLFR_DoSaveMode     = ASL_TB+44;  { Being used for saving?           }
  115.   ASLFR_DoMultiSelect  = ASL_TB+45;  { Do multi-select?                 }
  116.   ASLFR_DoPatterns     = ASL_TB+46;  { Display a Pattern gadget?        }
  117.  
  118. { Filtering }
  119.   ASLFR_DrawersOnly    = ASL_TB+47;  { Don't display files?             }
  120.   ASLFR_FilterFunc     = ASL_TB+49;  { Function to filter files         }
  121.   ASLFR_RejectIcons    = ASL_TB+60;  { Display .info files?             }
  122.   ASLFR_RejectPattern  = ASL_TB+61;  { Don't display files matching pat }
  123.   ASLFR_AcceptPattern  = ASL_TB+62;  { Accept only files matching pat   }
  124.   ASLFR_FilterDrawers  = ASL_TB+63;  { Also filter drawers with patterns}
  125.   ASLFR_HookFunc       = ASL_TB+7 ;  { Combined callback function       }
  126.  
  127. { Flag bits for the ASLFR_Flags1 tag }
  128.   FRB_FILTERFUNC     = 7;
  129.   FRB_INTUIFUNC      = 6;
  130.   FRB_DOSAVEMODE     = 5;
  131.   FRB_PRIVATEIDCMP   = 4;
  132.   FRB_DOMULTISELECT  = 3;
  133.   FRB_DOPATTERNS     = 0;
  134.  
  135.   FRF_FILTERFUNC     = 128;
  136.   FRF_INTUIFUNC      = 64;
  137.   FRF_DOSAVEMODE     = 32;
  138.   FRF_PRIVATEIDCMP   = 16;
  139.   FRF_DOMULTISELECT  = 8;
  140.   FRF_DOPATTERNS     = 1;
  141.  
  142. { Flag bits for the ASLFR_Flags2 tag }
  143.   FRB_DRAWERSONLY    = 0;
  144.   FRB_FILTERDRAWERS  = 1;
  145.   FRB_REJECTICONS    = 2;
  146.  
  147.   FRF_DRAWERSONLY    = 1;
  148.   FRF_FILTERDRAWERS  = 2;
  149.   FRF_REJECTICONS    = 4;
  150.  
  151.  
  152. {****************************************************************************
  153.  *
  154.  * ASL Font Requester data structures and constants
  155.  *
  156.  * This structure must only be allocated by asl.library amd is READ-ONLY!
  157.  * Control of the various fields is provided via tags when the requester
  158.  * is created with AllocAslRequest() and when it is displayed via
  159.  * AslRequest()
  160.  }
  161.  
  162. Type
  163.     pFontRequester = ^tFontRequester;
  164.     tFontRequester = record
  165.        fo_Reserved0        : Array[0..7] Of Byte;
  166.        fo_Attr             : tTextAttr;            { Returned TextAttr                }
  167.        fo_FrontPen         : Byte;                 { Returned front pen               }
  168.        fo_BackPen          : Byte;                 { Returned back pen                }
  169.        fo_DrawMode         : Byte;                 { Returned drawing mode            }
  170.        fo_Reserved1        : Byte;
  171.        fo_UserData         : Pointer;              { You can store your own data here }
  172.        fo_LeftEdge         : Integer;                 { Coordinates Of requester on Exit }
  173.        fo_TopEdge          : Integer;
  174.        fo_Width            : Integer;
  175.        fo_Height           : Integer;
  176.        fo_TAttr            : tTTextAttr;           { Returned TTextAttr               }
  177.     end;
  178.  
  179.  
  180. { Font requester tag values, used by AllocAslRequest() AND AslRequest() }
  181.  
  182. const
  183. { Window control }
  184.   ASLFO_Window         = ASL_TB+2 ;  { Parent window                    }
  185.   ASLFO_Screen         = ASL_TB+40;  { Screen to open on if no window   }
  186.   ASLFO_PubScreenName  = ASL_TB+41;  { Name of public screen            }
  187.   ASLFO_PrivateIDCMP   = ASL_TB+42;  { Allocate private IDCMP?          }
  188.   ASLFO_IntuiMsgFunc   = ASL_TB+70;  { Function to handle IntuiMessages }
  189.   ASLFO_SleepWindow    = ASL_TB+43;  { Block input in ASLFO_Window?     }
  190.   ASLFO_UserData       = ASL_TB+52;  { What to put in fo_UserData       }
  191.  
  192. { Text display }
  193.   ASLFO_TextAttr       = ASL_TB+51;  { Text font to use for gadget text }
  194.   ASLFO_Locale         = ASL_TB+50;  { Locale ASL should use for text   }
  195.   ASLFO_TitleText      = ASL_TB+1 ;  { Title of requester               }
  196.   ASLFO_PositiveText   = ASL_TB+18;  { Positive gadget text             }
  197.   ASLFO_NegativeText   = ASL_TB+19;  { Negative gadget text             }
  198.  
  199. { Initial settings }
  200.   ASLFO_InitialLeftEdge= ASL_TB+3 ;  { Initial requester coordinates    }
  201.   ASLFO_InitialTopEdge = ASL_TB+4 ;
  202.   ASLFO_InitialWidth   = ASL_TB+5 ;  { Initial requester dimensions     }
  203.   ASLFO_InitialHeight  = ASL_TB+6 ;
  204.   ASLFO_InitialName    = ASL_TB+10;  { Initial contents of Name gadget  }
  205.   ASLFO_InitialSize    = ASL_TB+11;  { Initial contents of Size gadget  }
  206.   ASLFO_InitialStyle   = ASL_TB+12;  { Initial font style               }
  207.   ASLFO_InitialFlags   = ASL_TB+13;  { Initial font flags for TextAttr  }
  208.   ASLFO_InitialFrontPen= ASL_TB+14;  { Initial front pen                }
  209.   ASLFO_InitialBackPen = ASL_TB+15;  { Initial back pen                 }
  210.   ASLFO_InitialDrawMode= ASL_TB+59;  { Initial draw mode                }
  211.  
  212. { Options }
  213.   ASLFO_Flags          = ASL_TB+20;  { Option flags                     }
  214.   ASLFO_DoFrontPen     = ASL_TB+44;  { Display Front color selector?    }
  215.   ASLFO_DoBackPen      = ASL_TB+45;  { Display Back color selector?     }
  216.   ASLFO_DoStyle        = ASL_TB+46;  { Display Style checkboxes?        }
  217.   ASLFO_DoDrawMode     = ASL_TB+47;  { Display DrawMode cycle gadget?   }
  218.  
  219. { Filtering }
  220.   ASLFO_FixedWidthOnly = ASL_TB+48;  { Only allow fixed-width fonts?    }
  221.   ASLFO_MinHeight      = ASL_TB+16;  { Minimum font height to display   }
  222.   ASLFO_MaxHeight      = ASL_TB+17;  { Maximum font height to display   }
  223.   ASLFO_FilterFunc     = ASL_TB+49;  { Function to filter fonts         }
  224.   ASLFO_HookFunc       = ASL_TB+7 ;  { Combined callback function       }
  225.   ASLFO_MaxFrontPen    = ASL_TB+66;  { Max # of colors in front palette }
  226.   ASLFO_MaxBackPen     = ASL_TB+67;  { Max # of colors in back palette  }
  227.  
  228. { Custom additions }
  229.   ASLFO_ModeList       = ASL_TB+21;  { Substitute list for drawmodes    }
  230.   ASLFO_FrontPens      = ASL_TB+64;  { Color table for front pen palette}
  231.   ASLFO_BackPens       = ASL_TB+65;  { Color table for back pen palette }
  232.  
  233. { Flag bits for ASLFO_Flags tag }
  234.   FOB_DOFRONTPEN    =  0;
  235.   FOB_DOBACKPEN     =  1;
  236.   FOB_DOSTYLE       =  2;
  237.   FOB_DODRAWMODE    =  3;
  238.   FOB_FIXEDWIDTHONLY=  4;
  239.   FOB_PRIVATEIDCMP  =  5;
  240.   FOB_INTUIFUNC     =  6;
  241.   FOB_FILTERFUNC    =  7;
  242.  
  243.   FOF_DOFRONTPEN     = 1;
  244.   FOF_DOBACKPEN      = 2;
  245.   FOF_DOSTYLE        = 4;
  246.   FOF_DODRAWMODE     = 8;
  247.   FOF_FIXEDWIDTHONLY = 16;
  248.   FOF_PRIVATEIDCMP   = 32;
  249.   FOF_INTUIFUNC      = 64;
  250.   FOF_FILTERFUNC     = 128;
  251.  
  252. {****************************************************************************
  253.  *
  254.  * ASL Screen Mode Requester data structures and constants
  255.  *
  256.  * This structure must only be allocated by asl.library and is READ-ONLY!
  257.  * Control of the various fields is provided via tags when the requester
  258.  * is created with AllocAslRequest() and when it is displayed via
  259.  * AslRequest()
  260.  }
  261.  
  262. Type
  263.  pScreenModeRequester = ^tScreenModeRequester;
  264.  tScreenModeRequester = record
  265.     sm_DisplayID        : ULONG;    { Display mode ID                  }
  266.     sm_DisplayWidth     : ULONG;    { Width Of display IN pixels       }
  267.     sm_DisplayHeight    : ULONG;    { Height Of display IN pixels      }
  268.     sm_DisplayDepth     : word;     { Number OF bit-planes OF display  }
  269.     sm_OverscanType     : word;     { TYPE OF overscan OF display      }
  270.     sm_AutoScroll       : Boolean;  { Display should auto-scroll?      }
  271.  
  272.     sm_BitMapWidth      : ULONG;    { Used TO create your own BitMap   }
  273.     sm_BitMapHeight     : ULONG;
  274.  
  275.     sm_LeftEdge         : Integer;     { Coordinates OF requester on Exit }
  276.     sm_TopEdge          : Integer;
  277.     sm_Width            : Integer;
  278.     sm_Height           : Integer;
  279.  
  280.     sm_InfoOpened       : Boolean;  { Info window opened on exit?      }
  281.     sm_InfoLeftEdge     : Integer;     { Last coordinates OF Info window  }
  282.     sm_InfoTopEdge      : Integer;
  283.     sm_InfoWidth        : Integer;
  284.     sm_InfoHeight       : Integer;
  285.  
  286.     sm_UserData         : Pointer;     { You can store your own data here }
  287.  END;
  288.  
  289.  
  290. { An Exec list of custom modes can be added to the list of available modes.
  291.  * The DimensionInfo structure must be completely initialized, including the
  292.  * Header. See <graphics/displayinfo.h>. Custom mode ID's must be in the range
  293.  * $FFFF0000..$FFFFFFFF. Regular properties which apply to your custom modes
  294.  * can be added in the dn_PropertyFlags field. Custom properties are not
  295.  * allowed.
  296.  }
  297.  pDisplayMode = ^tDisplayMode;
  298.  tDisplayMode = record
  299.     dm_Node     : tNode;                 { see ln_Name           }
  300.     dm_DimensionInfo : tDimensionInfo;   { mode description      }
  301.     dm_PropertyFlags : ULONG;           { applicable properties }
  302.  end;
  303.  
  304.  
  305. { ScreenMode requester tag values, used by AllocAslRequest() and AslRequest() }
  306. const
  307. { Window control }
  308.   ASLSM_Window        =  ASL_TB+2 ;  { Parent window                    }
  309.   ASLSM_Screen        =  ASL_TB+40;  { Screen to open on if no window   }
  310.   ASLSM_PubScreenName =  ASL_TB+41;  { Name of public screen            }
  311.   ASLSM_PrivateIDCMP  =  ASL_TB+42;  { Allocate private IDCMP?          }
  312.   ASLSM_IntuiMsgFunc  =  ASL_TB+70;  { Function to handle IntuiMessages }
  313.   ASLSM_SleepWindow   =  ASL_TB+43;  { Block input in ASLSM_Window?     }
  314.   ASLSM_UserData      =  ASL_TB+52;  { What to put in sm_UserData       }
  315.  
  316. { Text display }
  317.   ASLSM_TextAttr      =  ASL_TB+51;  { Text font to use for gadget text }
  318.   ASLSM_Locale        =  ASL_TB+50;  { Locale ASL should use for text   }
  319.   ASLSM_TitleText     =  ASL_TB+1 ;  { Title of requester               }
  320.   ASLSM_PositiveText  =  ASL_TB+18;  { Positive gadget text             }
  321.   ASLSM_NegativeText  =  ASL_TB+19;  { Negative gadget text             }
  322.  
  323. { Initial settings }
  324.   ASLSM_InitialLeftEdge      = ASL_TB+3  ; { Initial requester coordinates    }
  325.   ASLSM_InitialTopEdge       = ASL_TB+4  ;
  326.   ASLSM_InitialWidth         = ASL_TB+5  ; { Initial requester dimensions     }
  327.   ASLSM_InitialHeight        = ASL_TB+6  ;
  328.   ASLSM_InitialDisplayID     = ASL_TB+100; { Initial display mode id     }
  329.   ASLSM_InitialDisplayWidth  = ASL_TB+101; { Initial display width       }
  330.   ASLSM_InitialDisplayHeight = ASL_TB+102; { Initial display height      }
  331.   ASLSM_InitialDisplayDepth  = ASL_TB+103; { Initial display depth       }
  332.   ASLSM_InitialOverscanType  = ASL_TB+104; { Initial type of overscan    }
  333.   ASLSM_InitialAutoScroll    = ASL_TB+105; { Initial autoscroll setting  }
  334.   ASLSM_InitialInfoOpened    = ASL_TB+106; { Info wndw initially opened? }
  335.   ASLSM_InitialInfoLeftEdge  = ASL_TB+107; { Initial Info window coords. }
  336.   ASLSM_InitialInfoTopEdge   = ASL_TB+108;
  337.  
  338. { Options }
  339.   ASLSM_DoWidth         = ASL_TB+109;  { Display Width gadget?           }
  340.   ASLSM_DoHeight        = ASL_TB+110;  { Display Height gadget?          }
  341.   ASLSM_DoDepth         = ASL_TB+111;  { Display Depth gadget?           }
  342.   ASLSM_DoOverscanType  = ASL_TB+112;  { Display Overscan Type gadget?   }
  343.   ASLSM_DoAutoScroll    = ASL_TB+113;  { Display AutoScroll gadget?      }
  344.  
  345. { Filtering }
  346.   ASLSM_PropertyFlags   = ASL_TB+114;  { Must have these Property flags  }
  347.   ASLSM_PropertyMask    = ASL_TB+115;  { Only these should be looked at  }
  348.   ASLSM_MinWidth        = ASL_TB+116;  { Minimum display width to allow  }
  349.   ASLSM_MaxWidth        = ASL_TB+117;  { Maximum display width to allow  }
  350.   ASLSM_MinHeight       = ASL_TB+118;  { Minimum display height to allow }
  351.   ASLSM_MaxHeight       = ASL_TB+119;  { Maximum display height to allow }
  352.   ASLSM_MinDepth        = ASL_TB+120;  { Minimum display depth           }
  353.   ASLSM_MaxDepth        = ASL_TB+121;  { Maximum display depth           }
  354.   ASLSM_FilterFunc      = ASL_TB+122;  { Function to filter mode id's    }
  355.  
  356. { Custom additions }
  357.   ASLSM_CustomSMList    = ASL_TB+123;  { Exec list of struct DisplayMode }
  358.  
  359.  
  360. {****************************************************************************
  361.  *
  362.  * Obsolete ASL definitions, here for source code compatibility only.
  363.  * Please do NOT use in new code.
  364.  *
  365.  *   ASL_V38_NAMES_ONLY to remove these older names
  366.  }
  367. Const
  368.   ASL_Dummy       = (TAG_USER + $80000);
  369.   ASL_Hail        = ASL_Dummy+1 ;
  370.   ASL_Window      = ASL_Dummy+2 ;
  371.   ASL_LeftEdge    = ASL_Dummy+3 ;
  372.   ASL_TopEdge     = ASL_Dummy+4 ;
  373.   ASL_Width       = ASL_Dummy+5 ;
  374.   ASL_Height      = ASL_Dummy+6 ;
  375.   ASL_HookFunc    = ASL_Dummy+7 ;
  376.   ASL_File        = ASL_Dummy+8 ;
  377.   ASL_Dir         = ASL_Dummy+9 ;
  378.   ASL_FontName    = ASL_Dummy+10;
  379.   ASL_FontHeight  = ASL_Dummy+11;
  380.   ASL_FontStyles  = ASL_Dummy+12;
  381.   ASL_FontFlags   = ASL_Dummy+13;
  382.   ASL_FrontPen    = ASL_Dummy+14;
  383.   ASL_BackPen     = ASL_Dummy+15;
  384.   ASL_MinHeight   = ASL_Dummy+16;
  385.   ASL_MaxHeight   = ASL_Dummy+17;
  386.   ASL_OKText      = ASL_Dummy+18;
  387.   ASL_CancelText  = ASL_Dummy+19;
  388.   ASL_FuncFlags   = ASL_Dummy+20;
  389.   ASL_ModeList    = ASL_Dummy+21;
  390.   ASL_ExtFlags1   = ASL_Dummy+22;
  391.   ASL_Pattern     = ASL_FontName;
  392. { remember what I said up there? Do not use these anymore! }
  393.   FILB_DOWILDFUNC  = 7;
  394.   FILB_DOMSGFUNC   = 6;
  395.   FILB_SAVE        = 5;
  396.   FILB_NEWIDCMP    = 4;
  397.   FILB_MULTISELECT = 3;
  398.   FILB_PATGAD      = 0;
  399.   FILF_DOWILDFUNC  = 128;
  400.   FILF_DOMSGFUNC   = 64;
  401.   FILF_SAVE        = 32;
  402.   FILF_NEWIDCMP    = 16;
  403.   FILF_MULTISELECT = 8;
  404.   FILF_PATGAD      = 1;
  405.   FIL1B_NOFILES    = 0;
  406.   FIL1B_MATCHDIRS  = 1;
  407.   FIL1F_NOFILES    = 1;
  408.   FIL1F_MATCHDIRS  = 2;
  409.   FONB_FRONTCOLOR  = 0;
  410.   FONB_BACKCOLOR   = 1;
  411.   FONB_STYLES      = 2;
  412.   FONB_DRAWMODE    = 3;
  413.   FONB_FIXEDWIDTH  = 4;
  414.   FONB_NEWIDCMP    = 5;
  415.   FONB_DOMSGFUNC   = 6;
  416.   FONB_DOWILDFUNC  = 7;
  417.   FONF_FRONTCOLOR  = 1;
  418.   FONF_BACKCOLOR   = 2;
  419.   FONF_STYLES      = 4;
  420.   FONF_DRAWMODE    = 8;
  421.   FONF_FIXEDWIDTH  = 16;
  422.   FONF_NEWIDCMP    = 32;
  423.   FONF_DOMSGFUNC   = 64;
  424.   FONF_DOWILDFUNC  = 128;
  425.  
  426.  
  427. VAR AslBase : pLibrary;
  428.     asl_exit : Pointer;
  429.  
  430. FUNCTION AllocAslRequest(reqType : ULONG; tagList : pTagItem) : POINTER;
  431. FUNCTION AllocFileRequest : pFileRequester;
  432. FUNCTION AslRequest(requester : POINTER; tagList : pTagItem) : BOOLEAN;
  433. PROCEDURE FreeAslRequest(requester : POINTER);
  434. PROCEDURE FreeFileRequest(fileReq : pFileRequester);
  435. FUNCTION RequestFile(fileReq : pFileRequester) : BOOLEAN;
  436.  
  437. IMPLEMENTATION
  438.  
  439. uses msgbox;
  440.  
  441. FUNCTION AllocAslRequest(reqType : ULONG; tagList : pTagItem) : POINTER;
  442. BEGIN
  443.   ASM
  444.     MOVE.L  A6,-(A7)
  445.     MOVE.L  reqType,D0
  446.     MOVEA.L tagList,A0
  447.     MOVEA.L AslBase,A6
  448.     JSR -048(A6)
  449.     MOVEA.L (A7)+,A6
  450.     MOVE.L  D0,@RESULT
  451.   END;
  452. END;
  453.  
  454. FUNCTION AllocFileRequest : pFileRequester;
  455. BEGIN
  456.   ASM
  457.     MOVE.L  A6,-(A7)
  458.     MOVEA.L AslBase,A6
  459.     JSR -030(A6)
  460.     MOVEA.L (A7)+,A6
  461.     MOVE.L  D0,@RESULT
  462.   END;
  463. END;
  464.  
  465. FUNCTION AslRequest(requester : POINTER; tagList : pTagItem) : BOOLEAN;
  466. BEGIN
  467.   ASM
  468.     MOVE.L  A6,-(A7)
  469.     MOVEA.L requester,A0
  470.     MOVEA.L tagList,A1
  471.     MOVEA.L AslBase,A6
  472.     JSR -060(A6)
  473.     MOVEA.L (A7)+,A6
  474.     TST.W   D0
  475.     BEQ.B   @end
  476.     MOVEQ   #1,D0
  477.   @end: MOVE.B  D0,@RESULT
  478.   END;
  479. END;
  480.  
  481. PROCEDURE FreeAslRequest(requester : POINTER);
  482. BEGIN
  483.   ASM
  484.     MOVE.L  A6,-(A7)
  485.     MOVEA.L requester,A0
  486.     MOVEA.L AslBase,A6
  487.     JSR -054(A6)
  488.     MOVEA.L (A7)+,A6
  489.   END;
  490. END;
  491.  
  492. PROCEDURE FreeFileRequest(fileReq : pFileRequester);
  493. BEGIN
  494.   ASM
  495.     MOVE.L  A6,-(A7)
  496.     MOVEA.L fileReq,A0
  497.     MOVEA.L AslBase,A6
  498.     JSR -036(A6)
  499.     MOVEA.L (A7)+,A6
  500.   END;
  501. END;
  502.  
  503. FUNCTION RequestFile(fileReq : pFileRequester) : BOOLEAN;
  504. BEGIN
  505.   ASM
  506.     MOVE.L  A6,-(A7)
  507.     MOVEA.L fileReq,A0
  508.     MOVEA.L AslBase,A6
  509.     JSR -042(A6)
  510.     MOVEA.L (A7)+,A6
  511.     TST.W   D0
  512.     BEQ.B   @end
  513.     MOVEQ   #1,D0
  514.   @end: MOVE.B  D0,@RESULT
  515.   END;
  516. END;
  517.  
  518. procedure CloseAslLibrary;
  519. begin
  520.     ExitProc := asl_exit;
  521.     if AslBase <> nil then begin
  522.        CloseLibrary(AslBase);
  523.        AslBase := nil;
  524.     end;
  525. end;
  526.  
  527. const
  528.     VERSION : string[2] = '37';
  529.  
  530. begin
  531.     AslBase := nil;
  532.     AslBase := OpenLibrary(ASLNAME,37);
  533.     if AslBase <> nil then begin
  534.        asl_exit := ExitProc;
  535.        ExitProc := @CloseAslLibrary;
  536.     end else begin
  537.         MessageBox('FPC Pascal Error',
  538.                    'Can''t open asl.library version ' +
  539.                    VERSION +
  540.                    chr(10) + 
  541.                    'Deallocating resources and closing down',
  542.                    'Oops');
  543.        halt(20);
  544.     end;
  545.  
  546. END. (* UNIT ASL *)
  547.